package com.bdqn.Di3Zhan.Test;

import com.bdqn.Di3Zhan.MySqlDaoFactory;
import com.bdqn.Di3Zhan.entity.AbstractFactory;
import com.bdqn.Di3Zhan.entity.News;
import com.bdqn.Di3Zhan.entity.NewsDao;
import com.bdqn.Di3Zhan.entity.NewsServiceImpl;
import org.junit.Test;

public class NewsServiceImplTest {
//    @Test
//    public void addNews() throws Exception{
//        NewsDao dao = SimpleDaoFactory.getInstance("mysql");
//
//        NewsServiceImpl service = new NewsServiceImpl();
//
//        service.setDao(dao);
//
//        News news = new News();
//
//        news.setNtitle("测试标题2");
//        news.setNcontent("测试内容2");
//        service.addNews(news);
//    }

    @Test
    public void addNews() throws Exception{
        AbstractFactory factory = new MySqlDaoFactory();
        NewsDao dao = factory.getInstance();
        NewsServiceImpl service = new NewsServiceImpl();
        service.setDao(dao);

        News news = new News();
        news.setNtitle("测试标题4");
        news.setNcontent("测试内容4");
        service.addNews(news);
    }
}
